// filter.cpp
#include "filter.h"

LowPassFilter::LowPassFilter(double alpha)
    : alpha(alpha), prev_output(0.0), initialized(false) {}

double LowPassFilter::update(double input) {
    if (!initialized) {
        prev_output = input;
        initialized = true;
        return input;
    }
    prev_output = alpha * input + (1.0 - alpha) * prev_output;
    return prev_output;
}
